package cn.maihe.elg.operation.model.enums;

import java.util.Arrays;

/**
 * @Description
 * @Author WJH
 * @Date 2023/02/13
 */
public enum InvoiceReversalFlag {

    UNDO(0, "未冲红"),
    WAITING(1, "待冲红"),
    PROCESSING(2, "冲红中"),
    SUCCESS(3, "冲红成功"),
    FAILURE(4, "冲红失败"),
    ;

    private Integer flag;
    private String desc;

    InvoiceReversalFlag(Integer flag, String desc) {
        this.flag = flag;
        this.desc = desc;
    }

    public Integer getFlag() {
        return flag;
    }

    public String getDesc() {
        return desc;
    }

    public static InvoiceReversalFlag resolve(Integer flag) {
        if (flag == null) {
            return null;
        }
        return Arrays.stream(values()).filter(o -> o.getFlag().intValue() == flag).findFirst().orElse(null);
    }
}
